﻿using System;
using HslCommunication.Core;

namespace HslCommunication.BasicFramework
{
	/// <summary>
	/// 一个线程安全的缓存数据块，支持批量动态修改，添加，并获取快照<br />
	/// A thread-safe cache data block that supports batch dynamic modification, addition, and snapshot acquisition
	/// </summary>
	/// <remarks>
	/// 这个类可以实现什么功能呢，就是你有一个大的数组，作为你的应用程序的中间数据池，允许你往byte[]数组里存放指定长度的子byte[]数组，也允许从里面拿数据，
	/// 这些操作都是线程安全的，当然，本类扩展了一些额外的方法支持，也可以直接赋值或获取基本的数据类型对象。
	/// </remarks>
	/// <example>
	/// 此处举例一些数据的读写说明，可以此处的数据示例。
	/// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\BasicFramework\SoftBufferExample.cs" region="SoftBufferExample1" title="SoftBuffer示例" />
	/// </example>
	// Token: 0x0200018E RID: 398
	public class SoftBuffer : IDisposable
	{
		/// <summary>
		/// 使用默认的大小初始化缓存空间<br />
		/// Initialize cache space with default size
		/// </summary>
		// Token: 0x06002074 RID: 8308 RVA: 0x0009EA04 File Offset: 0x0009CC04
		public SoftBuffer()
		{
			this.buffer = new byte[this.capacity];
			this.hybirdLock = new SimpleHybirdLock();
			this.byteTransform = new RegularByteTransform();
		}

		/// <summary>
		/// 使用指定的容量初始化缓存数据块<br />
		/// Initialize the cache data block with the specified capacity
		/// </summary>
		/// <param name="capacity">初始化的容量</param>
		// Token: 0x06002075 RID: 8309 RVA: 0x0009EA58 File Offset: 0x0009CC58
		public SoftBuffer(int capacity)
		{
			this.buffer = new byte[capacity];
			this.capacity = capacity;
			this.hybirdLock = new SimpleHybirdLock();
			this.byteTransform = new RegularByteTransform();
		}

		/// <summary>
		/// 设置指定的位置bool值，如果超出，则丢弃数据，该位置是指按照位为单位排序的<br />
		/// Set the bool value at the specified position, if it is exceeded, 
		/// the data is discarded, the position refers to sorting in units of bits
		/// </summary>
		/// <param name="value">bool值</param>
		/// <param name="destIndex">目标存储的索引</param>
		/// <exception cref="T:System.IndexOutOfRangeException"></exception>
		// Token: 0x06002076 RID: 8310 RVA: 0x0009EAAC File Offset: 0x0009CCAC
		public void SetBool(bool value, int destIndex)
		{
			this.SetBool(new bool[]
			{
				value
			}, destIndex);
		}

		/// <summary>
		/// 设置指定的位置的bool数组，如果超出，则丢弃数据，该位置是指按照位为单位排序的<br />
		/// Set the bool array at the specified position, if it is exceeded, 
		/// the data is discarded, the position refers to sorting in units of bits
		/// </summary>
		/// <param name="value">bool数组值</param>
		/// <param name="destIndex">目标存储的索引</param>
		/// <exception cref="T:System.IndexOutOfRangeException"></exception>
		// Token: 0x06002077 RID: 8311 RVA: 0x0009EAC4 File Offset: 0x0009CCC4
		public void SetBool(bool[] value, int destIndex)
		{
			bool flag = value != null;
			if (flag)
			{
				try
				{
					this.hybirdLock.Enter();
					for (int i = 0; i < value.Length; i++)
					{
						int num = (destIndex + i) / 8;
						int offset = (destIndex + i) % 8;
						bool flag2 = this.isBoolReverseByWord;
						if (flag2)
						{
							bool flag3 = num % 2 == 0;
							if (flag3)
							{
								num++;
							}
							else
							{
								num--;
							}
						}
						bool flag4 = value[i];
						if (flag4)
						{
							this.buffer[num] = (this.buffer[num] | this.getOrByte(offset));
						}
						else
						{
							this.buffer[num] = (this.buffer[num] & this.getAndByte(offset));
						}
					}
					this.hybirdLock.Leave();
				}
				catch
				{
					this.hybirdLock.Leave();
					throw;
				}
			}
		}

		/// <summary>
		/// 获取指定的位置的bool值，如果超出，则引发异常<br />
		/// Get the bool value at the specified position, if it exceeds, an exception is thrown
		/// </summary>
		/// <param name="destIndex">目标存储的索引</param>
		/// <returns>获取索引位置的bool数据值</returns>
		/// <exception cref="T:System.IndexOutOfRangeException"></exception>
		// Token: 0x06002078 RID: 8312 RVA: 0x0009EBAC File Offset: 0x0009CDAC
		public bool GetBool(int destIndex)
		{
			return this.GetBool(destIndex, 1)[0];
		}

		/// <summary>
		/// 获取指定位置的bool数组值，如果超过，则引发异常<br />
		/// Get the bool array value at the specified position, if it exceeds, an exception is thrown
		/// </summary>
		/// <param name="destIndex">目标存储的索引</param>
		/// <param name="length">读取的数组长度</param>
		/// <exception cref="T:System.IndexOutOfRangeException"></exception>
		/// <returns>bool数组值</returns>
		// Token: 0x06002079 RID: 8313 RVA: 0x0009EBB8 File Offset: 0x0009CDB8
		public bool[] GetBool(int destIndex, int length)
		{
			bool[] array = new bool[length];
			try
			{
				this.hybirdLock.Enter();
				for (int i = 0; i < length; i++)
				{
					int num = (destIndex + i) / 8;
					int offset = (destIndex + i) % 8;
					bool flag = this.isBoolReverseByWord;
					if (flag)
					{
						bool flag2 = num % 2 == 0;
						if (flag2)
						{
							num++;
						}
						else
						{
							num--;
						}
					}
					array[i] = ((this.buffer[num] & this.getOrByte(offset)) == this.getOrByte(offset));
				}
				this.hybirdLock.Leave();
			}
			catch
			{
				this.hybirdLock.Leave();
				throw;
			}
			return array;
		}

		// Token: 0x0600207A RID: 8314 RVA: 0x0009EC74 File Offset: 0x0009CE74
		private byte getAndByte(int offset)
		{
			byte result;
			switch (offset)
			{
			case 0:
				result = 254;
				break;
			case 1:
				result = 253;
				break;
			case 2:
				result = 251;
				break;
			case 3:
				result = 247;
				break;
			case 4:
				result = 239;
				break;
			case 5:
				result = 223;
				break;
			case 6:
				result = 191;
				break;
			case 7:
				result = 127;
				break;
			default:
				result = byte.MaxValue;
				break;
			}
			return result;
		}

		// Token: 0x0600207B RID: 8315 RVA: 0x0009ECF4 File Offset: 0x0009CEF4
		private byte getOrByte(int offset)
		{
			byte result;
			switch (offset)
			{
			case 0:
				result = 1;
				break;
			case 1:
				result = 2;
				break;
			case 2:
				result = 4;
				break;
			case 3:
				result = 8;
				break;
			case 4:
				result = 16;
				break;
			case 5:
				result = 32;
				break;
			case 6:
				result = 64;
				break;
			case 7:
				result = 128;
				break;
			default:
				result = 0;
				break;
			}
			return result;
		}

		/// <summary>
		/// 设置指定的位置的数据块，如果超出，则丢弃数据<br />
		/// Set the data block at the specified position, if it is exceeded, the data is discarded
		/// </summary>
		/// <param name="data">数据块信息</param>
		/// <param name="destIndex">目标存储的索引</param>
		// Token: 0x0600207C RID: 8316 RVA: 0x0009ED5C File Offset: 0x0009CF5C
		public void SetBytes(byte[] data, int destIndex)
		{
			bool flag = destIndex < this.capacity && destIndex >= 0 && data != null;
			if (flag)
			{
				this.hybirdLock.Enter();
				bool flag2 = data.Length + destIndex > this.buffer.Length;
				if (flag2)
				{
					Array.Copy(data, 0, this.buffer, destIndex, this.buffer.Length - destIndex);
				}
				else
				{
					data.CopyTo(this.buffer, destIndex);
				}
				this.hybirdLock.Leave();
			}
		}

		/// <summary>
		/// 设置指定的位置的数据块，如果超出，则丢弃数据
		/// Set the data block at the specified position, if it is exceeded, the data is discarded
		/// </summary>
		/// <param name="data">数据块信息</param>
		/// <param name="destIndex">目标存储的索引</param>
		/// <param name="length">准备拷贝的数据长度</param>
		// Token: 0x0600207D RID: 8317 RVA: 0x0009EDDC File Offset: 0x0009CFDC
		public void SetBytes(byte[] data, int destIndex, int length)
		{
			bool flag = destIndex < this.capacity && destIndex >= 0 && data != null;
			if (flag)
			{
				bool flag2 = length > data.Length;
				if (flag2)
				{
					length = data.Length;
				}
				this.hybirdLock.Enter();
				bool flag3 = length + destIndex > this.buffer.Length;
				if (flag3)
				{
					Array.Copy(data, 0, this.buffer, destIndex, this.buffer.Length - destIndex);
				}
				else
				{
					Array.Copy(data, 0, this.buffer, destIndex, length);
				}
				this.hybirdLock.Leave();
			}
		}

		/// <summary>
		/// 设置指定的位置的数据块，如果超出，则丢弃数据<br />
		/// Set the data block at the specified position, if it is exceeded, the data is discarded
		/// </summary>
		/// <param name="data">数据块信息</param>
		/// <param name="sourceIndex">Data中的起始位置</param>
		/// <param name="destIndex">目标存储的索引</param>
		/// <param name="length">准备拷贝的数据长度</param>
		/// <exception cref="T:System.IndexOutOfRangeException"></exception>
		// Token: 0x0600207E RID: 8318 RVA: 0x0009EE6C File Offset: 0x0009D06C
		public void SetBytes(byte[] data, int sourceIndex, int destIndex, int length)
		{
			bool flag = destIndex < this.capacity && destIndex >= 0 && data != null;
			if (flag)
			{
				bool flag2 = length > data.Length;
				if (flag2)
				{
					length = data.Length;
				}
				this.hybirdLock.Enter();
				Array.Copy(data, sourceIndex, this.buffer, destIndex, length);
				this.hybirdLock.Leave();
			}
		}

		/// <summary>
		/// 获取内存指定长度的数据信息<br />
		/// Get data information of specified length in memory
		/// </summary>
		/// <param name="index">起始位置</param>
		/// <param name="length">数组长度</param>
		/// <returns>返回实际的数据信息</returns>
		// Token: 0x0600207F RID: 8319 RVA: 0x0009EED0 File Offset: 0x0009D0D0
		public byte[] GetBytes(int index, int length)
		{
			byte[] array = new byte[length];
			bool flag = length > 0;
			if (flag)
			{
				this.hybirdLock.Enter();
				bool flag2 = index >= 0 && index + length <= this.buffer.Length;
				if (flag2)
				{
					Array.Copy(this.buffer, index, array, 0, length);
				}
				this.hybirdLock.Leave();
			}
			return array;
		}

		/// <summary>
		/// 获取内存所有的数据信息<br />
		/// Get all data information in memory
		/// </summary>
		/// <returns>实际的数据信息</returns>
		// Token: 0x06002080 RID: 8320 RVA: 0x0009EF39 File Offset: 0x0009D139
		public byte[] GetBytes()
		{
			return this.GetBytes(0, this.capacity);
		}

		/// <summary>
		/// 设置byte类型的数据到缓存区<br />
		/// Set byte type data to the cache area
		/// </summary>
		/// <param name="value">byte数值</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002081 RID: 8321 RVA: 0x0009EF48 File Offset: 0x0009D148
		public void SetValue(byte value, int index)
		{
			this.SetBytes(new byte[]
			{
				value
			}, index);
		}

		/// <summary>
		/// 设置short数组的数据到缓存区<br />
		/// Set short array data to the cache area
		/// </summary>
		/// <param name="values">short数组</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002082 RID: 8322 RVA: 0x0009EF5C File Offset: 0x0009D15C
		public void SetValue(short[] values, int index)
		{
			this.SetBytes(this.byteTransform.TransByte(values), index);
		}

		/// <summary>
		/// 设置short类型的数据到缓存区<br />
		/// Set short type data to the cache area
		/// </summary>
		/// <param name="value">short数值</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002083 RID: 8323 RVA: 0x0009EF72 File Offset: 0x0009D172
		public void SetValue(short value, int index)
		{
			this.SetValue(new short[]
			{
				value
			}, index);
		}

		/// <summary>
		/// 设置ushort数组的数据到缓存区<br />
		/// Set ushort array data to the cache area
		/// </summary>
		/// <param name="values">ushort数组</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002084 RID: 8324 RVA: 0x0009EF86 File Offset: 0x0009D186
		public void SetValue(ushort[] values, int index)
		{
			this.SetBytes(this.byteTransform.TransByte(values), index);
		}

		/// <summary>
		/// 设置ushort类型的数据到缓存区<br />
		/// Set ushort type data to the cache area
		/// </summary>
		/// <param name="value">ushort数值</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002085 RID: 8325 RVA: 0x0009EF9C File Offset: 0x0009D19C
		public void SetValue(ushort value, int index)
		{
			this.SetValue(new ushort[]
			{
				value
			}, index);
		}

		/// <summary>
		/// 设置int数组的数据到缓存区<br />
		/// Set int array data to the cache area
		/// </summary>
		/// <param name="values">int数组</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002086 RID: 8326 RVA: 0x0009EFB0 File Offset: 0x0009D1B0
		public void SetValue(int[] values, int index)
		{
			this.SetBytes(this.byteTransform.TransByte(values), index);
		}

		/// <summary>
		/// 设置int类型的数据到缓存区<br />
		/// Set int type data to the cache area
		/// </summary>
		/// <param name="value">int数值</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002087 RID: 8327 RVA: 0x0009EFC6 File Offset: 0x0009D1C6
		public void SetValue(int value, int index)
		{
			this.SetValue(new int[]
			{
				value
			}, index);
		}

		/// <summary>
		/// 设置uint数组的数据到缓存区<br />
		/// Set uint array data to the cache area
		/// </summary>
		/// <param name="values">uint数组</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002088 RID: 8328 RVA: 0x0009EFDA File Offset: 0x0009D1DA
		public void SetValue(uint[] values, int index)
		{
			this.SetBytes(this.byteTransform.TransByte(values), index);
		}

		/// <summary>
		/// 设置uint类型的数据到缓存区<br />
		/// Set uint byte data to the cache area
		/// </summary>
		/// <param name="value">uint数值</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002089 RID: 8329 RVA: 0x0009EFF0 File Offset: 0x0009D1F0
		public void SetValue(uint value, int index)
		{
			this.SetValue(new uint[]
			{
				value
			}, index);
		}

		/// <summary>
		/// 设置float数组的数据到缓存区<br />
		/// Set float array data to the cache area
		/// </summary>
		/// <param name="values">float数组</param>
		/// <param name="index">索引位置</param>
		// Token: 0x0600208A RID: 8330 RVA: 0x0009F004 File Offset: 0x0009D204
		public void SetValue(float[] values, int index)
		{
			this.SetBytes(this.byteTransform.TransByte(values), index);
		}

		/// <summary>
		/// 设置float类型的数据到缓存区<br />
		/// Set float type data to the cache area
		/// </summary>
		/// <param name="value">float数值</param>
		/// <param name="index">索引位置</param>
		// Token: 0x0600208B RID: 8331 RVA: 0x0009F01A File Offset: 0x0009D21A
		public void SetValue(float value, int index)
		{
			this.SetValue(new float[]
			{
				value
			}, index);
		}

		/// <summary>
		/// 设置long数组的数据到缓存区<br />
		/// Set long array data to the cache area
		/// </summary>
		/// <param name="values">long数组</param>
		/// <param name="index">索引位置</param>
		// Token: 0x0600208C RID: 8332 RVA: 0x0009F02E File Offset: 0x0009D22E
		public void SetValue(long[] values, int index)
		{
			this.SetBytes(this.byteTransform.TransByte(values), index);
		}

		/// <summary>
		/// 设置long类型的数据到缓存区<br />
		/// Set long type data to the cache area
		/// </summary>
		/// <param name="value">long数值</param>
		/// <param name="index">索引位置</param>
		// Token: 0x0600208D RID: 8333 RVA: 0x0009F044 File Offset: 0x0009D244
		public void SetValue(long value, int index)
		{
			this.SetValue(new long[]
			{
				value
			}, index);
		}

		/// <summary>
		/// 设置ulong数组的数据到缓存区<br />
		/// Set long array data to the cache area
		/// </summary>
		/// <param name="values">ulong数组</param>
		/// <param name="index">索引位置</param>
		// Token: 0x0600208E RID: 8334 RVA: 0x0009F058 File Offset: 0x0009D258
		public void SetValue(ulong[] values, int index)
		{
			this.SetBytes(this.byteTransform.TransByte(values), index);
		}

		/// <summary>
		/// 设置ulong类型的数据到缓存区<br />
		/// Set ulong byte data to the cache area
		/// </summary>
		/// <param name="value">ulong数值</param>
		/// <param name="index">索引位置</param>
		// Token: 0x0600208F RID: 8335 RVA: 0x0009F06E File Offset: 0x0009D26E
		public void SetValue(ulong value, int index)
		{
			this.SetValue(new ulong[]
			{
				value
			}, index);
		}

		/// <summary>
		/// 设置double数组的数据到缓存区<br />
		/// Set double array data to the cache area
		/// </summary>
		/// <param name="values">double数组</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002090 RID: 8336 RVA: 0x0009F082 File Offset: 0x0009D282
		public void SetValue(double[] values, int index)
		{
			this.SetBytes(this.byteTransform.TransByte(values), index);
		}

		/// <summary>
		/// 设置double类型的数据到缓存区<br />
		/// Set double type data to the cache area
		/// </summary>
		/// <param name="value">double数值</param>
		/// <param name="index">索引位置</param>
		// Token: 0x06002091 RID: 8337 RVA: 0x0009F098 File Offset: 0x0009D298
		public void SetValue(double value, int index)
		{
			this.SetValue(new double[]
			{
				value
			}, index);
		}

		/// <summary>
		/// 获取byte类型的数据<br />
		/// Get byte data
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <returns>byte数值</returns>
		// Token: 0x06002092 RID: 8338 RVA: 0x0009F0AC File Offset: 0x0009D2AC
		public byte GetByte(int index)
		{
			return this.GetBytes(index, 1)[0];
		}

		/// <summary>
		/// 获取short类型的数组到缓存区<br />
		/// Get short type array to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <param name="length">数组长度</param>
		/// <returns>short数组</returns>
		// Token: 0x06002093 RID: 8339 RVA: 0x0009F0B8 File Offset: 0x0009D2B8
		public short[] GetInt16(int index, int length)
		{
			return this.byteTransform.TransInt16(this.GetBytes(index, length * 2), 0, length);
		}

		/// <summary>
		/// 获取short类型的数据到缓存区<br />
		/// Get short data to the cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <returns>short数据</returns>
		// Token: 0x06002094 RID: 8340 RVA: 0x0009F0D1 File Offset: 0x0009D2D1
		public short GetInt16(int index)
		{
			return this.GetInt16(index, 1)[0];
		}

		/// <summary>
		/// 获取ushort类型的数组到缓存区<br />
		/// Get ushort type array to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <param name="length">数组长度</param>
		/// <returns>ushort数组</returns>
		// Token: 0x06002095 RID: 8341 RVA: 0x0009F0DD File Offset: 0x0009D2DD
		public ushort[] GetUInt16(int index, int length)
		{
			return this.byteTransform.TransUInt16(this.GetBytes(index, length * 2), 0, length);
		}

		/// <summary>
		/// 获取ushort类型的数据到缓存区<br />
		/// Get ushort type data to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <returns>ushort数据</returns>
		// Token: 0x06002096 RID: 8342 RVA: 0x0009F0F6 File Offset: 0x0009D2F6
		public ushort GetUInt16(int index)
		{
			return this.GetUInt16(index, 1)[0];
		}

		/// <summary>
		/// 获取int类型的数组到缓存区<br />
		/// Get int type array to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <param name="length">数组长度</param>
		/// <returns>int数组</returns>
		// Token: 0x06002097 RID: 8343 RVA: 0x0009F102 File Offset: 0x0009D302
		public int[] GetInt32(int index, int length)
		{
			return this.byteTransform.TransInt32(this.GetBytes(index, length * 4), 0, length);
		}

		/// <summary>
		/// 获取int类型的数据到缓存区<br />
		/// Get int type data to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <returns>int数据</returns>
		// Token: 0x06002098 RID: 8344 RVA: 0x0009F11B File Offset: 0x0009D31B
		public int GetInt32(int index)
		{
			return this.GetInt32(index, 1)[0];
		}

		/// <summary>
		/// 获取uint类型的数组到缓存区<br />
		/// Get uint type array to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <param name="length">数组长度</param>
		/// <returns>uint数组</returns>
		// Token: 0x06002099 RID: 8345 RVA: 0x0009F127 File Offset: 0x0009D327
		public uint[] GetUInt32(int index, int length)
		{
			return this.byteTransform.TransUInt32(this.GetBytes(index, length * 4), 0, length);
		}

		/// <summary>
		/// 获取uint类型的数据到缓存区<br />
		/// Get uint type data to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <returns>uint数据</returns>
		// Token: 0x0600209A RID: 8346 RVA: 0x0009F140 File Offset: 0x0009D340
		public uint GetUInt32(int index)
		{
			return this.GetUInt32(index, 1)[0];
		}

		/// <summary>
		/// 获取float类型的数组到缓存区<br />
		/// Get float type array to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <param name="length">数组长度</param>
		/// <returns>float数组</returns>
		// Token: 0x0600209B RID: 8347 RVA: 0x0009F14C File Offset: 0x0009D34C
		public float[] GetSingle(int index, int length)
		{
			return this.byteTransform.TransSingle(this.GetBytes(index, length * 4), 0, length);
		}

		/// <summary>
		/// 获取float类型的数据到缓存区<br />
		/// Get float type data to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <returns>float数据</returns>
		// Token: 0x0600209C RID: 8348 RVA: 0x0009F165 File Offset: 0x0009D365
		public float GetSingle(int index)
		{
			return this.GetSingle(index, 1)[0];
		}

		/// <summary>
		/// 获取long类型的数组到缓存区<br />
		/// Get long type array to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <param name="length">数组长度</param>
		/// <returns>long数组</returns>
		// Token: 0x0600209D RID: 8349 RVA: 0x0009F171 File Offset: 0x0009D371
		public long[] GetInt64(int index, int length)
		{
			return this.byteTransform.TransInt64(this.GetBytes(index, length * 8), 0, length);
		}

		/// <summary>
		/// 获取long类型的数据到缓存区<br />
		/// Get long type data to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <returns>long数据</returns>
		// Token: 0x0600209E RID: 8350 RVA: 0x0009F18A File Offset: 0x0009D38A
		public long GetInt64(int index)
		{
			return this.GetInt64(index, 1)[0];
		}

		/// <summary>
		/// 获取ulong类型的数组到缓存区<br />
		/// Get ulong type array to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <param name="length">数组长度</param>
		/// <returns>ulong数组</returns>
		// Token: 0x0600209F RID: 8351 RVA: 0x0009F196 File Offset: 0x0009D396
		public ulong[] GetUInt64(int index, int length)
		{
			return this.byteTransform.TransUInt64(this.GetBytes(index, length * 8), 0, length);
		}

		/// <summary>
		/// 获取ulong类型的数据到缓存区<br />
		/// Get ulong type data to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <returns>ulong数据</returns>
		// Token: 0x060020A0 RID: 8352 RVA: 0x0009F1AF File Offset: 0x0009D3AF
		public ulong GetUInt64(int index)
		{
			return this.GetUInt64(index, 1)[0];
		}

		/// <summary>
		/// 获取double类型的数组到缓存区<br />
		/// Get double type array to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <param name="length">数组长度</param>
		/// <returns>double数组</returns>
		// Token: 0x060020A1 RID: 8353 RVA: 0x0009F1BB File Offset: 0x0009D3BB
		public double[] GetDouble(int index, int length)
		{
			return this.byteTransform.TransDouble(this.GetBytes(index, length * 8), 0, length);
		}

		/// <summary>
		/// 获取double类型的数据到缓存区<br />
		/// Get double type data to cache
		/// </summary>
		/// <param name="index">索引位置</param>
		/// <returns>double数据</returns>
		// Token: 0x060020A2 RID: 8354 RVA: 0x0009F1D4 File Offset: 0x0009D3D4
		public double GetDouble(int index)
		{
			return this.GetDouble(index, 1)[0];
		}

		/// <summary>
		/// 读取自定义类型的数据，需要规定解析规则<br />
		/// Read custom types of data, need to specify the parsing rules
		/// </summary>
		/// <typeparam name="T">类型名称</typeparam>
		/// <param name="index">起始索引</param>
		/// <returns>自定义的数据类型</returns>
		// Token: 0x060020A3 RID: 8355 RVA: 0x0009F1E0 File Offset: 0x0009D3E0
		public T GetCustomer<T>(int index) where T : IDataTransfer, new()
		{
			T result = Activator.CreateInstance<T>();
			byte[] bytes = this.GetBytes(index, (int)result.ReadCount);
			result.ParseSource(bytes);
			return result;
		}

		/// <summary>
		/// 写入自定义类型的数据到缓存中去，需要规定生成字节的方法<br />
		/// Write custom type data to the cache, need to specify the method of generating bytes
		/// </summary>
		/// <typeparam name="T">自定义类型</typeparam>
		/// <param name="data">实例对象</param>
		/// <param name="index">起始地址</param>
		// Token: 0x060020A4 RID: 8356 RVA: 0x0009F21D File Offset: 0x0009D41D
		public void SetCustomer<T>(T data, int index) where T : IDataTransfer, new()
		{
			this.SetBytes(data.ToSource(), index);
		}

		/// <inheritdoc cref="P:HslCommunication.Core.Net.NetworkDoubleBase.ByteTransform" />
		// Token: 0x170006A8 RID: 1704
		// (get) Token: 0x060020A5 RID: 8357 RVA: 0x0009F234 File Offset: 0x0009D434
		// (set) Token: 0x060020A6 RID: 8358 RVA: 0x0009F23C File Offset: 0x0009D43C
		public IByteTransform ByteTransform
		{
			get
			{
				return this.byteTransform;
			}
			set
			{
				this.byteTransform = value;
			}
		}

		/// <summary>
		/// 获取或设置当前的bool操作是否按照字节反转<br />
		/// Gets or sets whether the current bool operation is reversed by bytes
		/// </summary>
		// Token: 0x170006A9 RID: 1705
		// (get) Token: 0x060020A7 RID: 8359 RVA: 0x0009F245 File Offset: 0x0009D445
		// (set) Token: 0x060020A8 RID: 8360 RVA: 0x0009F24D File Offset: 0x0009D44D
		public bool IsBoolReverseByWord
		{
			get
			{
				return this.isBoolReverseByWord;
			}
			set
			{
				this.isBoolReverseByWord = value;
			}
		}

		/// <summary>
		/// 释放当前的对象
		/// </summary>
		/// <param name="disposing"></param>
		// Token: 0x060020A9 RID: 8361 RVA: 0x0009F258 File Offset: 0x0009D458
		protected virtual void Dispose(bool disposing)
		{
			bool flag = !this.disposedValue;
			if (flag)
			{
				if (disposing)
				{
					SimpleHybirdLock simpleHybirdLock = this.hybirdLock;
					if (simpleHybirdLock != null)
					{
						simpleHybirdLock.Dispose();
					}
					this.buffer = null;
				}
				this.disposedValue = true;
			}
		}

		/// <inheritdoc cref="M:System.IDisposable.Dispose" />
		// Token: 0x060020AA RID: 8362 RVA: 0x0009F29C File Offset: 0x0009D49C
		public void Dispose()
		{
			this.Dispose(true);
		}

		/// <inheritdoc />
		// Token: 0x060020AB RID: 8363 RVA: 0x0009F2A7 File Offset: 0x0009D4A7
		public override string ToString()
		{
			return string.Format("SoftBuffer[{0}][{1}]", this.capacity, this.ByteTransform);
		}

		// Token: 0x040007B2 RID: 1970
		private int capacity = 10;

		// Token: 0x040007B3 RID: 1971
		private byte[] buffer;

		// Token: 0x040007B4 RID: 1972
		private SimpleHybirdLock hybirdLock;

		// Token: 0x040007B5 RID: 1973
		private IByteTransform byteTransform;

		// Token: 0x040007B6 RID: 1974
		private bool isBoolReverseByWord = false;

		// Token: 0x040007B7 RID: 1975
		private bool disposedValue = false;
	}
}
